<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-09-22 10:13:41
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" inventory
-->
<template>
  <sc-VxeTable
    ref="xGrid"
    :gridEvts="gridEvents"
    :tablecode="'finance_balance_account'"
    :url="api.finance.balance.account"
    :params="{ parent_id: 1002 }"
  >
  </sc-VxeTable>

  <browser
    v-if="dialog.browser"
    ref="browserDialog"
    :title="title"
    :params="browserparems"
    :urlParams="urlParams"
    @success="handleSuccess"
    @closed="dialog.browser = false"
  ></browser>
</template>
<script>
export default {
  name: "finance_generalLedger_payable",
};
</script>
<script setup>
// import { useRouter } from "vue-router";
import { ref, nextTick } from "vue";
// , onMounted, reactive, ref
// const router = useRouter();
import browser from "./browser";

import api from "@/api";
const dialog = ref({
  browser: false,
});

const xGrid = ref({});
const browserDialog = ref({});
const browserparems = ref({});
const title = ref("");
const handleSuccess = () => {
  xGrid.value.refresh();
};
const urlParams = ref({});
const gridEvents = {
  cellDblclick: function ({ row }) {
    gridEvents.edit(row);
  },

  edit: function (data) {
    if (typeof data.$grid !== "undefined") {
      data = data.$grid.getCheckboxRecords()[0];
    }
    title.value = "[" + data.name + "]-科目明细账";
    browserparems.value = {
      subject_id: { type: "lk", value: data.code },
    };
    urlParams.value = {
      params: {
        direct: data.direct_id,
        type: "accont",
        billdate: xGrid.value.gridOptions.formConfig.items[0].defaultvalue,
      },
    };
    dialog.value.browser = true;
    nextTick(() => {
      browserDialog.value.open();
    });
  },
};
</script>
